﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Df.Common.Forms.JsonFormatter;
using Df.Common.Forms.Validation;
using Newtonsoft.Json;

namespace Df.Common.Forms
{
    [FluentValidation.Attributes.Validator(typeof(EmailValidator))]
    [JsonConverter(typeof(ElementConverter))]
    public class DfEmail : DfTextBox
    {
        public DfEmail()
        {
            _invalidEmailMessage = "Invalid email address";
        }

        private string _invalidEmailMessage;
        public string InvalidEmailMessage
        {
            get { return _invalidEmailMessage; }
            set { _invalidEmailMessage = value; }
        }

        [EmailAddress(ErrorMessage = "Invalid Email Address")]
        [DataType(DataType.EmailAddress)]
        public override string Value
        {
            get
            {
                return base.Value;
            }
            set
            {
                base.Value = value;
            }
        }
    }
}
